package edu.mis.modules.categoryOfGoods;

import com.jfinal.core.Controller;
import com.jfinal.kit.StrKit;
import com.jfinal.validate.Validator;

public class CategoryOfGoodsValidator extends Validator {

	@Override
	protected void validate(Controller c) {
		validateString("name", 1, 30, "name", "类别名称长度不能超过30");
		validateRequired("name", "name", "类别名称不能为空");
		if(StrKit.notBlank(c.getPara("description")))
			validateString("description", 1, 100, "description", "长度不能超过100");
	}

	@Override
	protected void handleError(Controller c) {
		c.setAttr("result", false);
		c.renderJson();
	}

}
